<?php
require_once('kernel.inc');

if($AUTH->logedstatus === true && $AUTH->permission == 'system')
{
   switch ($action)
   {
      case 1:
         $vars = $MECCANO->GetSysVars($id);
         $str = '';

         if($vars != false)
         {

            for($i=0,$t=count($vars); $i<$t; $i++)
            {
               $str .= $vars[$i]['var_name'].'##'.$vars[$i]['type'].'##'.$vars[$i]['var_value'].'##'.$vars[$i]['description'].'^^';
            }
         }

         echo $str;
         exit();

      case 2:
         $Vname   = isset($_POST['Vname'])   ? $_POST['Vname']   : false;
         $newData = isset($_POST['newData']) ? $_POST['newData'] : false;
         if($MECCANO->UpdateSysVars($Vname, $newData))
         {
            echo 1;
         } else
         {
            echo 0;
         }
         exit();

      default:
         $SMARTY->assign('modules', $MECCANO->kernel);
         $SMARTY->display('admin.configure.tpl.html');
   }
} else
{
   $AUTH->frame_redirector();
}